<%--
    Document   : adresses
    Created on : 26 mai 2012, 17:53:31
    Author     : Thomas
--%>

<%@page import="java.util.HashMap" %>

<%@include file="_header.jsp" %>
<%@include file="_left.jsp" %>

<%! String error_msg; %>
<% error_msg = (String)request.getAttribute("error_msg"); %>

<%! Customer customer; %>
<% customer = (Customer) request.getSession().getAttribute("customer"); %>

<%! HashMap<String, Boolean> errorMap; %>
<% errorMap = (HashMap<String, Boolean>)request.getAttribute("errorMap"); %>

<div class="span7">
<% if (error_msg != null) { %>
    <h3>Oups !</h3>
    <br/>
    <div class="alert-error"><strong><%= error_msg %></strong></div>
    <hr/>
    <div class="row-fluid">
        <div class="pull-right">
            <a class="btn btn-primary" href="<%= request.getContextPath() %>">OK</a>
        </div>
    </div>
<% } else { %>
    <h3>Ma commande : adresse (&eacute;tape 2/5)</h3>
    <br/>
    <p>
        <em>Merci de nous fournir l'adresse qui sera utilis&eacute;e pour la livraison et la facturation de votre commande.</em>
    </p>
    <br/>
    <form class="form-horizontal" method="post" action="<%= request.getContextPath() %>/Order?action=editerAdresse">
        <% if (errorMap != null && errorMap.get("line1") != null && errorMap.get("line1") == false) { %>
        <div class="control-group error">
            <label class="control-label" for="line1">Adresse ligne 1</label>
            <div class="controls">
                <input type="text" name="line1" class="span3" <% if(customer.getAddress().getLine1() != null) { %> value="<%= customer.getAddress().getLine1() %>" <% } %> placeholder="Enter your address line 1..."/>
                <span class="help-inline"><i class="icon-exclamation-sign"></i></span>
                <span class="help-block">La ligne 1 est requise.</span>
            </div>
        </div>
        <% } else { %>
        <div class="control-group">
            <label class="control-label" for="line1">Adresse ligne 1</label>
            <div class="controls">
                <input type="text" name="line1" class="span3" <% if(customer.getAddress().getLine1() != null) { %> value="<%= customer.getAddress().getLine1() %>" <% } %> placeholder="Enter your address line 1..."/>
            </div>
        </div>
        <% } %>
        <div class="control-group">
            <label class="control-label" for="line2">Adresse ligne 2</label>
            <div class="controls">
                <input type="text" name="line2" class="span3" <% if(customer.getAddress().getLine2() != null) { %> value="<%= customer.getAddress().getLine2() %>" <% } %> placeholder="Enter your address line 2..."/>
                <span class="help-inline">facultatif</span>
            </div>
        </div>
        <% if (errorMap != null && errorMap.get("zipcode") != null && errorMap.get("zipcode") == false) { %>
        <div class="control-group error">
            <label class="control-label" for="zipcode">Code Postal</label>
            <div class="controls">
                <input type="text" name="zipcode" class="span1" <% if(customer.getAddress().getZipCode() != null) { %> value="<%= customer.getAddress().getZipCode() %>" <% } %> placeholder="Zipcode..."/>
                <span class="help-inline"><i class="icon-exclamation-sign"></i></span>
                <span class="help-block">Le code postal est requis.</span>
            </div>
        </div>
        <% } else { %>
        <div class="control-group">
            <label class="control-label" for="zipcode">Code Postal</label>
            <div class="controls">
                <input type="text" name="zipcode" class="span1" <% if(customer.getAddress().getZipCode() != null) { %> value="<%= customer.getAddress().getZipCode() %>" <% } %> placeholder="Zipcode..."/>
            </div>
        </div>
        <% } %>
        <% if (errorMap != null && errorMap.get("city") != null && errorMap.get("city") == false) { %>
        <div class="control-group error">
            <label class="control-label" for="city">Ville</label>
            <div class="controls">
                <input type="text" name="city" class="span3" <% if(customer.getAddress().getCity() != null) { %> value="<%= customer.getAddress().getCity() %>" <% } %> placeholder="Enter your city..."/>
                <span class="help-inline"><i class="icon-exclamation-sign"></i></span>
                <span class="help-block">La ville est requise.</span>
            </div>
        </div>
        <% } else { %>
        <div class="control-group">
            <label class="control-label" for="city">Ville</label>
            <div class="controls">
                <input type="text" name="city" class="span3" <% if(customer.getAddress().getCity() != null) { %> value="<%= customer.getAddress().getCity() %>" <% } %> placeholder="Enter your city..."/>
            </div>
        </div>
        <% } %>
        <div class="control-group">
            <label class="control-label" for="country">Pays</label>
            <div class="controls">
                <input type="text" name="country" class="span3" <% if(customer.getAddress().getCountry() != null) { %> value="<%= customer.getAddress().getCountry() %>" <% } %> placeholder="Enter your country..."/>
            </div>
        </div>
        <hr/>
        <div class="row-fluid">
            <div class="pull-left">
                <input type="submit" class="btn btn-danger" name="cancel" value="annuler"/>
            </div>
            <div class="pull-right">
                <input type="submit" class="btn" name="previous" value="&larr;&nbsp;client"/>
                <input type="submit" class="btn btn-primary" name="next" value="articles&nbsp;&rarr;"/>
            </div>
        </div>
    </form>
<% } %>
</div>

<%@include file="_right.jsp" %>
<%@include file="_footer.jsp" %>